/*
 *  $Id: Phoenix.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *  This file is a part of Ragima CCG.
 *  (C) 2008 Ragima development group.
 *
 *  Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Fire.Creatures {
    public class Phoenix: CreatureCard {
        public Phoenix(): base("001_f_c_phoenix") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Fire;
            Value = 100;
            MaxCount = 1;
            Damage = 4;
            Health = 7;
            AddManaCost(ElementType.Fire, 8);
        }
        public override void SetNaturalAffects(ICollector<Affect> affects) {
            affects.Add<Affects.MagicAttack>();
            affects.Add<Affects.Flight>();
            affects.Add(new Affects.Reincarnation(3));
            affects.Add(new Affects.Immune(DamageType.Fire));
            affects.Add<PhoenixAffect>();
        }

        private class PhoenixAffect: Affect {
            public override string Id {
                get { return AffectManager.GetCardId<Phoenix>("wings"); }
            }

            public override void SetAffect() {
                base.SetAffect();
                LocalSummary.OnUntap += DoPhoenix;
            }
            public override void ResetAffect() {
                base.ResetAffect();
                LocalSummary.OnUntap -= DoPhoenix;
            }

            private void DoPhoenix(Creature phoenix) {
                foreach (Creature victim in phoenix.Owner.GetCreatures())
                    if (victim != phoenix && victim.DistanceTo(phoenix) == 1)
                        victim.DamageBy(NewDamage(DamageType.Fire, 3));
            }
        }
    }
}
